let containerEl = document.querySelector(".container");

import {
    gameOver
} from './event.js';
import {
    maskEl,
    userNumEl,
    openArray,
    coinsEl,
    checkEl,
    stateEl
} from './varible.js';
import {
    playClick
} from './method.js';
import {
    inputIsEmpty
} from './check.js';
import {
    loadGame
} from './load.js';

if (window.localStorage.getItem("studentId") != null) {
    maskEl.style.display = "none";
    userNumEl.innerHTML = window.localStorage.getItem("studentId");
} else {
    maskEl.style.display = "flex";
}
//菜单栏
playClick();
//是否输入了学号
inputIsEmpty();
// document.body.onbeforeunload = function () {
//     window.event.returnValue = '您即将离开本页面，游戏进度将不会保存，确定继续吗？';
// }

let checkPoint = "1";
let storage = window.localStorage;
if (!window.localStorage) {
    alert("该浏览器不支持localStorage");
} else if (storage.getItem("check") == null) {
    // let storage = window.localStorage;
    storage.setItem("check", checkPoint);
    storage.setItem("coins", "500");
    checkEl.innerHTML = "第1关";
} else {
    coinsEl.innerHTML = parseInt(storage.getItem("coins"));
    checkEl.innerHTML = "第" + storage.getItem("check") + "关";
}
if (parseInt(storage.getItem("state")) == 1) {
    stateEl.style.display = "none";
} else {
    // stateEl.style.display = "block";
}
loadGame((parseInt(storage.getItem("check")) + "/" + parseInt(storage.getItem("check")) + ".json"));
gameOver();